package ATMAgain;

import ATM.AskFrame;
import ATM.MyButton;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MainFrame extends JFrame {

    ICodeService service = new CodeServiceImpl();

    public MainFrame(){
        this.setLayout(null);

        this.init();

        this.setSize(500,300);
        this.setVisible(true);
        this.setDefaultCloseOperation(3);
        this.setLocationRelativeTo(null);
    }

    private void init(){
        MyButton askButton = new ATM.MyButton("查询",100,50,this);
        MyButton pwdChangeButton = new ATM.MyButton("改密码",100,120,this);
        MyButton saveButton = new ATM.MyButton("存钱",300,40,this);
        MyButton getMoneyButton = new ATM.MyButton("取款",300,90,this);
        MyButton takeCardButton = new MyButton("取卡",300,140,this);
        MyButton transMoneyButton = new MyButton("转账",100,190,this);

        askButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                MainFrame.this.dispose();
                new FindFrame();
            }
        });

        transMoneyButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                MainFrame.this.dispose();
                new TransMoneyFrame();
            }
        });

        saveButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                MainFrame.this.dispose();
                new MoneySaveFrame();
            }
        });

        getMoneyButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                MainFrame.this.dispose();
                new TakeMoneyFrame();
            }
        });

        pwdChangeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                MainFrame.this.dispose();
                new ChangePwdFrame();
            }
        });

        takeCardButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });


    }


}
